﻿
//添加原告&被告表格
function addyg(tag) {
    var tbl = null;
    switch (tag) {
        case 1:
            tbl = document.getElementById("tblygzyr");
            break;
        case 2:
            tbl = document.getElementById("tblygfr");
            break;
        case 3:
            tbl = document.getElementById("tblygother");
            break;
        case 5:
            tbl = document.getElementById("tblbgzyr");
            break;
        case 6:
            tbl = document.getElementById("tblbgfr");
            break;
        case 7:
            tbl = document.getElementById("tblbgother");
            break;
        default:
            break;
    }

    var newtbl = tbl.cloneNode(true);
    newtbl.id = newtbl.id + "_" + tag.toString();
    var el = null;
    if (tag < 5) {
        el = document.getElementById("liyg");
    } else {
        el = document.getElementById("libg");
    }
    el.appendChild(newtbl);
}

//删除添加的表格
function deltbl(el) {
    if (confirm("您确定要删除吗？")) {
        var eTbl = el.parentNode.parentNode.parentNode.parentNode;
        eTbl.removeNode(true);
    }
}

function ResPostData() {
    //原告/上诉人
    var liyg = document.getElementById("liyg");

    var atbes = liyg.getElementsByTagName("table");

    //原告信息
    var yglist = "";
    for (var t = 0; t < atbes.length; t++) {
        var otbl = atbes[t];

        var entity = "0"; //当事人类型（0：原告；1：被告）
        var id = otbl.id.toString().substring(otbl.id.length - 1, otbl.id.length);
        entity += "&" + id; ; //当事人分类（1：自然人；2：法人；3：非法人其他组织）
        var ainputs = otbl.getElementsByTagName("input");
        for (var i = 1; i < ainputs.length; i++) {
            var oin = ainputs[i];
            entity += "&" + oin.value;
        }
        yglist += "~" + entity;
    }

    //被告信息
    var libg = document.getElementById("libg");
    var abgtbes = libg.getElementsByTagName("table");
    var bglist = "";
    for (var t = 0; t < abgtbes.length; t++) {
        var otbl = abgtbes[t];

        var entity = "1"; //当事人类型（0：原告；1：被告）
        var id = otbl.id.toString().substring(otbl.id.length - 1, otbl.id.length);
        //当事人分类（1：自然人；2：法人；3：非法人其他组织）
        switch (id) {
            case "5":
                entity += "&1";
                break;
            case "6":
                entity += "&2";
                break;
            case "7":
                entity += "&3";
                break;
        }
        var ainputs = otbl.getElementsByTagName("input");
        for (var i = 1; i < ainputs.length; i++) {
            var oin = ainputs[i];
            entity += "&" + oin.value;
        }
        bglist += "~" + entity;
    }

    document.getElementById("AppContent").value = yglist + "$" + bglist;

    return true;
}